package org.wmine.preprocess;

import java.util.Random;
import java.util.Vector;

import javax.swing.table.DefaultTableModel;

public class Numerosity
{
	DefaultTableModel dtm;
	public Numerosity(DefaultTableModel dtm)
	{
		this.dtm=dtm;
	}
	public void Numerosity_Random(int samples)
	{
		int samples_removed=dtm.getRowCount()-samples;
		Random r= new Random();
		PreprocessPanel.report.append("<br>You have Selected to Perform Numerosity Reduction Randomly<br> Rows Removed are <br>");
		
		
		for(int i=0;i<samples_removed;i++)
		{
			
			int random=r.nextInt(this.dtm.getRowCount()-1);
			Vector v=this.dtm.getDataVector();
			PreprocessPanel.report.append((i+1)+" : "+v.get(random)+"<br>");
			PreprocessPanel.report_summary.setText(PreprocessPanel.report.toString());
			this.dtm.removeRow(random);
		}
	}
	public void Numerosity_Manual(int [] selected_rows)
	{
		int cnt=0;
		PreprocessPanel.report.append("<br>You have Selected to Perform Numerosity Reduction Manually<br> Rows Removed are <br>");
		for(int i=0;i<selected_rows.length;i++)
		{
			
			Vector v=this.dtm.getDataVector();
			PreprocessPanel.report.append((i+1)+" :: "+v.get(selected_rows[i]-cnt)+"<br>");
			PreprocessPanel.report_summary.setText(PreprocessPanel.report.toString());
			this.dtm.removeRow(selected_rows[i]-cnt);
			cnt++;
		}
	}
	
}
